package com.czh.rdm.chat_1

import java.util.*


class Rectangle(val width: Int, val height: Int) {
    val isEqual: Boolean
        get() = height == width
}

fun createRectangle(): Rectangle {
    return Rectangle(Random().nextInt(), Random().nextInt())
}

fun bimMetric(
    weight: Double,
    height: Double
): String {
    val bim = weight / (height * height)
    println("Bim Metric: $bim")
    return if (bim < 18.5) {
        "体重过轻"
    } else if (bim < 25) {
        "正常体重"
    } else {
        "体重过重"
    }
}

fun main(args: Array<String>) {
    val rectangle = createRectangle()
    println(rectangle.isEqual)

    val oneToTen = 1..10
    println(oneToTen)
    for (x in oneToTen) {
        println(x)
    }

    // 遍历一个map
    val binaryMap = TreeMap<Char, String>()
    for (c in 'A'..'F') {
        val binary = Integer.toBinaryString(c.code)
        binaryMap[c] = binary
    }
    for ((letter, binary) in binaryMap) {
        println("$letter = $binary")
    }

    println("----------")
    println(bimMetric(68.0, 1.65))
    println("_________")
    val values = 1..10
    println(values)
    println(3 in values)
    for (i in values) {
        println(i)
    }
}